<?php
declare (strict_types=1);

namespace app\course\logic\coupon\admin;

use app\admin\logic\system\Log;
use app\common\exception\LogicException;
use app\course\model\coupon\admin\CouponCard as CouponCardModel;

/**
 * 后台优惠券逻辑层
 */
class CouponCard extends CouponCardModel
{
    /**
     * 获取优惠券列表
     * Author   Martinsun<syh@sunyonghong.com>
     * Date 2020-05-13
     *
     * @return   [type]                         [description]
     */
    public function getList(array $map = [], $online = 1)
    {
        if ($online) {
            return $this->with(['school'])->where($map)->order('update_time', 'DESC')->paginate($this->getListRows());
        }

        return $this->with(['school'])->withCount(['offline'])->where($map)->order('update_time', 'DESC')->paginate($this->getListRows())->hidden(['count']);
    }
}
